package br.com.pfc.mobile.activity;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
import android.widget.ListView;
import br.com.mobile.listadapter.ClienteListAdapter;
import br.com.pfc.mobile.transferobject.ClienteTO;
import br.com.pfc.mobile.util.MobileSession;

public class ListaClienteActivity extends ListActivity {

	private List<ClienteTO> lista;
	@Override
	public void onCreate(Bundle icicle){
		super.onCreate(icicle);
		Map sessao = MobileSession.getSessao();
		lista = (List<ClienteTO>) sessao.get("clientes");
		setListAdapter(new ClienteListAdapter(this, lista));
	}
	
	@Override
	protected void onListItemClick(ListView l, View v, int posicao, long codigo){
		super.onListItemClick(l, v, posicao, codigo);
		Intent it = getIntent();
		it.putExtra("cliente", lista.get(posicao));
		it.setClass(ListaClienteActivity.this, DetalharClienteActivity.class);
		startActivity(it);
	}
}
